<template>
  <div class="g-container">
    <div class="g-line"></div>
    <div class="g-ground"></div>
    <div class="g-man">
      <div class="g-hand"></div>
    </div>
    <div class="g-name">{{ name }}</div>
  </div>
</template>

<script>
import "@/styles/peopleName.css";
export default {
  data() {
    return {
      studentList: [
        "过成牛",
        "小孟",
        "张文妹",
        "姬鹏飞",
        "张亮",
        "缪加俊",
        "杨永帅",
        "李泽惠",
        "胡琴",
      ],
      name: "过成牛",
      timer: null,
    };
  },
  methods: {
    fn() {
      //   let random
      //   setInterval(function () {
      //     random = Math.floor(Math.random() * this.studentList[length])
      //   this.name = this.studentList[random]

      //   }, 1000)
      //   console.log(random)

      clearInterval(this.timer);
      this.timer = setInterval(() => {
        // 开启定时器
        const i = Math.floor(Math.random() * 9); // 16数组长度
        this.name = this.studentList[i]; // i 数组索引
      }, 6000); // 100是每个时间
    },
  },
  mounted() {
    this.fn();
  },
};
</script>

<style>
</style>
